using IM.Easy.Core.ServiceLifetime;
using IM.Easy.Core.Services;
using IM.Easy.Core.Utils;
using IM.Easy.Infrastructure.Query;
using IM.Easy.Entity.System;
using IM.Easy.SystemServices.Dtos;
using Microsoft.AspNetCore.Http;

namespace IM.Easy.SystemServices.IServices
{
    public interface IFileResourceService : IAppServices<FileResource>
    {
        /// <summary>
        /// 创建一个新实体
        /// </summary>
        /// <param name="entity">要创建的实体</param>
        /// <returns>创建后的实体</returns>
        FileResource Create(FileResource entity);

        /// <summary>
        /// 根据 ID 获取实体
        /// </summary>
        /// <param name="id">实体的唯一标识</param>
        /// <returns>获取的实体</returns>
        FileResourceDto GetById(Guid id);

        /// <summary>
        /// 获取所有实体
        /// </summary>
        /// <returns>所有实体的列表</returns>
        PageResponse<FileResource> GetPageList(FileResourceQueryDto query);

        /// <summary>
        /// 更新一个已有的实体
        /// </summary>
        /// <param name="entity">更新后的实体</param>
        /// <returns>更新后的实体</returns>
        bool Update(FileResource entity);

        /// <summary>
        /// 根据 ID 删除实体
        /// </summary>
        /// <param name="id">要删除的实体的唯一标识</param>
        /// <returns>返回物理存储路径</returns>
        List<string> Delete(params Guid[] key);

        /// <summary>
        /// 通过文件夹id删除文件
        /// </summary>
        /// <param name="fid"></param>
        /// <returns>返回物理存储地址</returns>
        List<string> DeleteByFolder(Guid fid);

        /// <summary>
        /// 删除文件    物理存储数据
        /// </summary>
        /// <param name="path"></param>
        void DeleteStorage(params string[] path);

        /// <summary>
        /// 存储文件到服务器
        /// </summary>
        /// <param name="file"></param>
        /// <param name="folder"></param>
        /// <returns></returns>
        Task<string> LocalStorage(IFormFile file, params string[] folder);

        /// <summary>
        /// 将本地资源文件路径映射为静态资源的网络地址
        /// </summary>
        /// <param name="path">本地文件路径（例如：D:\upload\a.jpg）</param>
        /// <returns>静态资源的网络地址，例如 /static/upload/a.jpg</returns>
        string MapToNetworkUrl(string path);

        /// <summary>
        /// 重命名
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        bool Rename(Guid id, string name);
    }
}
